{extend name='public/layer_base' /}
{block name='content'}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <div class="layui-row">
                <form class="layui-form" method="post">

                    <div class="layui-form-item">
                        <label for="nickname" class="layui-form-label">角色</label>
                        <div class="layui-input-inline">
                            <div id="role"></div>
                        </div>
                    </div>
                    <script>
                        var role = xmSelect.render({
                            el: '#role', 
                            filterable: true,
                            name:'role',
                            data: [
                            {foreach name='role' item='item'}
                                {name: '{$item.name}', value: {$item.id},{if isset($data) && in_array($item.id,$data.role)}selected:true{/if}},
                                {/foreach}
                            ]
                        })
                        </script>

                    <div class="layui-form-item">
                        <label for="nickname" class="layui-form-label">昵称</label>
                        <div class="layui-input-inline">
                            <input maxlength="50" id="nickname" name="nickname" value="{$data.nickname|default=''}"
                                class="layui-input" placeholder="请输入昵称">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label for="username" class="layui-form-label">账号</label>
                        <div class="layui-input-inline">
                            <input maxlength="50" id="username" name="username"  value="{$data.username|default=''}"
                                class="layui-input" placeholder="请输入账号">

                        </div>
                    </div>

                    <div class="layui-form-item">
                        <label for="L_pass" class="layui-form-label"> 密码</label>
                        <div class="layui-input-inline">
                            <input type="password" id="L_pass" name="password" required="" lay-verify="pass"
                                autocomplete="off" value="{$data.password|default=''}" class="layui-input">
                        </div>
                        <div class="layui-form-mid layui-word-aux">6到12个字符</div>
                    </div>
                    <div class="layui-form-item">
                        <label for="nickname" class="layui-form-label">
                            启用状态</label>
                        <div class="layui-input-inline">
                            <input type="checkbox" lay-skin="switch" lay-filter="status" value="1" {if isset($data) &&
                                $data.status==1} checked {/if}>
                            <input type="hidden" name="status" value="{$data.status|default='0'}">
                        </div>
                        <script>
                            layui.use('form', function () {
                                var form = layui.form;
                                form.on('switch(status)', function (data) {
                                    $('input[name=status]').val(data.elem.checked ? '1' : '0');
                                })
                            })
                        </script>
                    </div>
                    <div class="layui-form-item">
                        <label for="L_repass" class="layui-form-label"></label>
                        <button class="layui-btn" lay-filter="submit" id="submit" lay-submit="submit"
                            type="button">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

{/block}